import Vue from 'vue'
import App from './App.vue'
import router from './router'
import './plugins/element.js'
import './assets/css/global.css'
import axios from 'axios'
import './assets/fonts/iconfont.css'

import TreeTable from 'vue-table-with-tree-grid'

// 倒入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'


// 引入NProgress
import NProgress from 'nprogress'
// 全局引入echarts
import * as echarts from 'echarts';
Vue.prototype.$echarts = echarts


Vue.config.productionTip = false
// 将富文本编辑器注册为全局可用的组件
Vue.use(VueQuillEditor)
//全局注册组件
Vue.component('tree-table', TreeTable)

// axios配置
axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
// 请求拦截器 在发送request时添加NProgress.start();
axios.interceptors.request.use(config => {
  // console.log(config);
  NProgress.start();
  config.headers.Authorization = window.sessionStorage.getItem('token');
  return config
})
axios.interceptors.response.use(config => {
  NProgress.done();
  return config
})
// 在发送response请求时添加NProgress.done();
Vue.prototype.$http = axios

// 时间过滤器dateFormat 
Vue.filter('dateFormat', function (originVals) {
  const dt = new Date(originVals);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + '').padStart(2, '0');
  const d = (dt.getDate() + '').padStart(2, '0');

  const hh = (dt.getHours() + '').padStart(2, '0');
  const mm = (dt.getMinutes() + '').padStart(2, '0');
  const ss = (dt.getSeconds() + '').padStart(2, '0')
  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})



new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
